# Importing Data
INDONESIA<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Rubber/Rubber.xlsx",sheet = "Sheet1", range = "e1:e325")

# Checking the Imported Data
View(INDONESIA)
# Creating Time Series Data
INDONESIA_ts <- ts(INDONESIA, start=c(1991,1), end=c(2017,12), frequency=12)
# Viewing and Checking the Created Time Series Data
INDONESIA_ts
sum(is.na(INDONESIA_ts))
library(forecast)
INDONESIA_ts <- tsclean(INDONESIA_ts)
INDONESIA_ts

# Identification: Plotting the Time Series Data
plot(INDONESIA_ts)

# Estimating the appropriate model
INDONESIA_ts_model <- auto.arima(INDONESIA_ts)
INDONESIA_ts_model

# Forecasting
options(max.print=1000000)
INDONESIA_ts_forecast <- forecast (INDONESIA_ts_model, level=c(95), h=276)
plot(INDONESIA_ts_forecast)
INDONESIA_ts_forecast             

# Exporting
write.table(INDONESIA_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Rubber/INDONESIA_TSA.csv", sep=",")


